package connect;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;

import util.ByteBuffer;

public class MyDeCoder extends CumulativeProtocolDecoder{

    protected boolean doDecode(IoSession arg0, IoBuffer in,
            ProtocolDecoderOutput out) throws Exception
    {
    	
		if(in.remaining() < 4 )
		{
			System.err.println("MyDeCoder false.................");
			return false;
		}
		int size = in.getInt();
		
		ByteBuffer data = new ByteBuffer();
		in.get(data.getBytes(), 0, size);
		out.write(data);
	    return true;
    }


}
